import 'package:flutter/material.dart';

import 'hi_barrage_transition.dart';

class HiBarrageTrack extends StatelessWidget {
  final double top;
  final Duration speed;
  final Widget child;
  final ValueChanged<Widget>? onComplete;

  HiBarrageTrack(
      {super.key,
      required this.top,
      required this.child,
      this.onComplete,
      required this.speed});

  //fix 动画状态错乱
  final _key = GlobalKey<HiBarrageTransitionState>();

  @override
  Widget build(BuildContext context) {
    return Positioned.fill(
      top: top,
      child: HiBarrageTransition(
        key: _key,
        onComplete: () {
          onComplete?.call(this);
        },
        speed: speed,
        child: child,
      ),
    );
  }
}
